﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Timers;

namespace LoggingService
{
    public partial class Service1 : ServiceBase
    {
        Timer t1 = new Timer();

        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {

            t1.Interval = 30000;
            t1.Elapsed += new ElapsedEventHandler(Worker);
            t1.Start();
        }

        protected override void OnStop()
        {
            t1.Stop();
        }

        public void Worker(object w, ElapsedEventArgs e)
        {
            using (StreamWriter sw = new StreamWriter("c:\\Temp\\Test.txt", true))
            {
                sw.WriteLine("test");
                sw.Close();
            }
        }
   
    }
}
